home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZSEKFIL.C < prev    next >
Text File  |  1988-12-18  |  995b  |  41 lines

  1.  
  2. /*
  3. ┌────────────────────────────────────────────────────────────────────────────┐
  4. │jzsekfil.c                                     │
  5. │Seek forwards or backwards in a file                         │
  6. │Parms                                         │
  7. │  whandle      handle of file to seek                     │
  8. │  Offset      Distance to seek (Long Integer)                 │
  9. │  Method      0 = offset from beginning,1 = offset from current loc,     │
  10. │          2 = end of file + offset.                     │
  11. │  Returns      Offset from beginning of file.                 │
  12. └────────────────────────────────────────────────────────────────────────────┘
  13. */
  14.  
  15. #include <jaz.h>
  16.  
  17. long jzsekfil(fhandle,foffset,fmethod)
  18. int fhandle;
  19. unsigned long foffset;
  20. int fmethod;
  21.  
  22. {
  23.   TREG wreg;
  24.  
  25.   wreg.h.ah = 0x42 ;            /* seek file */
  26.   wreg.h.al = fmethod;
  27.  
  28.   wreg.x.dx = (int) (foffset & 0xFFFFL);
  29.  
  30.   wreg.x.cx = (int) ((foffset & 0xFFFF0000L) >> 8);
  31.  
  32.   wreg.x.bx = fhandle;
  33.  
  34.   msdos(&wreg);
  35.  
  36.   if (wreg.x.flags & 1)
  37.     return(-1L);
  38.   else
  39.     return((long)((wreg.x.dx << 8) + wreg.x.ax));
  40. }
  41.